Map Links
The maps URL scheme is used to show geographical locations and to generate driving directions between two points. If your app includes address or location information, you can use map links to open that information in the Maps app in iOS or macOS.
Unlike some schemes, map URLs do not start with a “maps” scheme identifier. Instead, map links are specified as regular http
links and are opened either in Safari or the Maps app on the target platform.
Table 5-1 lists the supported parameters along with a brief description of each.
Parameter | Meaning | Values |
---|---|---|
| The map type. If you don’t specify one of the documented values, the current map type is used. |
|
| The query. This parameter is treated as if its value had been typed into the Maps search field by the user. Note that The | A URL-encoded string that describes the search object, such as “pizza,” or an address to be geocoded |
| The address. Using the address parameter simply displays the specified location, it does not perform a search for the location. | An address string that geolocation can understand. |
| A hint used during search. If the | A comma-separated pair of floating point values that represent latitude and longitude (in that order). |
| The location around which the map should be centered. The | A comma-separated pair of floating point values that represent latitude and longitude (in that order). |
| The zoom level. You can use the | A floating point value between |
| The area around the center point, or span. The center point is specified by the You can’t use the | A coordinate span (see MKCoordinateSpan) denoting a latitudinal delta and a longitudinal delta. |
| The source address to be used as the starting point for directions. A complete directions request includes the | An address string that geolocation can understand. |
| The destination address to be used as the destination point for directions. A complete directions request includes the | An address string that geolocation can understand. |
| The transport type. A complete directions request includes the |
|
| The search location. You can specify the | A comma-separated pair of floating point values that represent latitude and longitude (in that order). |
| The screen span. Use the | A coordinate span (see MKCoordinateSpan) denoting a latitudinal delta and a longitudinal delta. |
You can use the maps URL scheme to help the user:
Perform a search
Get directions to a location
View a specific location
To perform a search, supply a properly encoded URL string as the value of the q
parameter. For example:
http://maps.apple.com/?q=Mexican+Restaurant |
To specify a location for search, you can supply a value for the near
parameter, or combine the sll
parameter with either the z
or sspn
parameters. You can also set the map type using the t
parameter, as shown here:
http://maps.apple.com/?q=Mexican+Restaurant&sll=50.894967,4.341626&z=10&t=s |
To provide navigation directions from one location to another, supply the start and destination addresses in the saddr
and daddr
parameters as shown below. You can also supply much more detail for the start and destination addresses than is shown here.
http://maps.apple.com/?saddr=Cupertino&daddr=San+Francisco |
To specify a transport type, you can use the dirflg
parameter as shown here:
http://maps.apple.com/?saddr=San+Jose&daddr=San+Francisco&dirflg=r |
You can omit the start address when you want to provide directions “from here.” The following example shows a search from here that provides driving directions in a hybrid map.
http://maps.apple.com/?daddr=San+Francisco&dirflg=d&t=h |
To display a specific location, use the ll
parameter to center the map at the specified position as shown here:
http://maps.apple.com/?ll=50.894967,4.341626 |
Another way to display a location is to specify an address, such as:
http://maps.apple.com/?address=1,Infinite+Loop,Cupertino,California |
If you use both the ll
and address
parameters, ll
takes precedence over address
. If you include a name in the value of the q
parameter, Maps tries to match the name at the specified location.
Copyright © 2017 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2017-09-19